package cn.edu.thu.tsquality.core.common.util;

import java.util.Arrays;

/**
 * Created by wangyihan  on 2018/4/26 上午10:49.
 * E-mail address is yihanwang22@163.com.
 * Copyright © 2017 wangyihan. All Rights Reserved.
 *
 * @author wangyihan
 */
public class ArgumentsHelper {
  public final static String argsDelimiter = "&";
  public final static String valuesDelimiter = ",";

  public static String[] getArguments(String args) {
    return args.split(argsDelimiter);
  }

  public static String[] getValues(String values) {
    if (values.startsWith("{") || values.startsWith("[")) {
      values = values.substring(1, values.length() - 1);
    }
    return values.split(valuesDelimiter);
  }

  public static String buildValues(String[] values) {
    return String.format("{%s}", String.join(",", Arrays.asList(values)));
  }
}
